package com.itheima.reggie.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.itheima.reggie.common.R;
import com.itheima.reggie.dto.OrdersDto;
import com.itheima.reggie.entity.Orders;
import com.itheima.reggie.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.xml.crypto.Data;
import java.time.LocalDateTime;
import java.util.Date;

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {

 @Autowired
 private OrderService orderService;
 @PostMapping("/submit")
 public R<String> submit(@RequestBody Orders orders){
  log.info("orders :{}",orders);

  orderService.submit(orders);
  return R.success("下单成功");
 }
@GetMapping("/page")
 public  R<Page<OrdersDto>> page (Integer page, Integer pageSize, Long orderID,String beginTime, String endTime){
  log.info("分页查询");

 Page<OrdersDto> pageOrderDto = orderService.page(page, pageSize, orderID, beginTime, endTime);

 return R.success(pageOrderDto);
}

}
